/*
 * @Author: Otway
 * @Date: 2019-01-09 11:16:08
 * @LastEditors: Otway
 * @LastEditTime: 2019-08-30 18:50:09
 * @copyright: h-visions
 */
import React, { PureComponent } from 'react';
import {
    Row,
    Col,
    Form,
    Input,
    Select,
} from 'antd';
const FormItem = Form.Item;
const { Option } = Select
const formItemLayout = {
    // 抽屉里面Form。二列的布局比例
    labelCol: {
        span: 6
    },
    wrapperCol: {
        span: 18
    }
};
class AddFrom extends PureComponent {
    render() {
        const {
            one: one,
            formData: formData,
            form: { getFieldDecorator },
        } = this.props;
        console.log('编辑还是新增', one);
        console.log('传递过来的数据', formData);
        return (
            <Form >
                <Row>
                    <Col span={24}>
                        <FormItem {...formItemLayout} label={'类别:'}>
                            {getFieldDecorator('type', {
                                initialValue: one ? formData.type : '',
                                rules: [
                                    {
                                        required: true,
                                        message: '请选择类别'
                                    }
                                ]
                            })(
                                <Select allowClear={true}>
                                    <Option value={'自检'}>自检</Option>
                                    <Option value={'试机'}>试机</Option>
                                    <Option value={'质检'}>质检</Option>
                                </Select>
                            )}
                        </FormItem>
                    </Col>
                    <Col span={24}>
                        <FormItem {...formItemLayout} label={'要求项目内容:'}>
                            {getFieldDecorator('itemRequirement', {
                                initialValue: one ? formData.itemRequirement : '',
                                rules: [
                                    {
                                        required: true,
                                        message: '要求项目内容不能为空'
                                    }
                                ]
                            })(
                                <Input placeholder='请输入要求项目内容' allowClear={true} maxLength={20} />
                            )}
                        </FormItem>
                    </Col>
                    <Col span={24}>
                        <FormItem {...formItemLayout} label={'备注:'}>
                            {getFieldDecorator('remark', {
                                initialValue: one ? formData.remark : '',
                                rules: [
                                    {
                                        required: false,
                                        message: '备注不能为空'
                                    }
                                ]
                            })(<Input placeholder='输入备注' allowClear={true} maxLength={20} />)}
                        </FormItem>
                    </Col>
                </Row>
            </Form>
        );
    }
}
export default Form.create()(AddFrom);
